package ThreadPool.lagou.concurrent.completableFuture.demo01;

import java.util.concurrent.CompletableFuture;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description: 对计算结果进行消费
 * @date 2022/10/7 16:41
 */
public class CompletetableFutureAPI3Demo {

    public static void main(String[] args) {
//        CompletableFuture.supplyAsync(()->{
//            return 1;
//        }).thenApply(f->{
//            return f+1;
//        }).thenApply(f->{
//            return f+2;
//        }).thenAccept(System.out::println);
        System.out.println(CompletableFuture.supplyAsync(() -> "oyz").thenRun(() -> {
        }).join());
        System.out.println(CompletableFuture.supplyAsync(() -> "oyz").thenApply(r -> r + " No 1").join());

//        CompletableFuture.supplyAsync(() -> "oyz").thenAccept(r -> System.out.println(r)).join();

        System.out.println(CompletableFuture.supplyAsync(() -> "oyz").thenAccept(r -> System.out.println(r)).join());
    }

}
